package com.panshi.sendEmail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SendEmailIdentifyServiceImp implements SendEmailIdentifyService {

    @Resource
    JavaMailSender jms;

    @Override
    public String sendMessage(String sender, String receiver, String title, String text) {
        //建立邮件信息
        SimpleMailMessage smm = new SimpleMailMessage();

        System.out.println("发送者");
        smm.setFrom(sender);

        System.out.println("接收者");
        smm.setTo(receiver);

        //发送的标题
        smm.setSubject(title);

        //发送的内容
        smm.setText(text);

        jms.send(smm);

        return "index";
    }
}
